// pages/myRecomVip/myRecomVip.js
const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight: app.globalData.statusBarHeight,
    fullHeight: app.globalData.fullcontain,
    navmess: {
      navtitle: "我推荐的会员",
      backhide: 0,
      topheight: 1
    },
    //下拉列表的数据
    selectShow: false,
    selectData: ['全部','2','3'],
    index: 0,
    // ajaxdemo
    demolist: {
      "pages": 2, 
      "page1":[
          {
          "imghUrl": "./images/demoimg.png",
          "name": "特朗普",
          "phone": "2311231231",
          "lastConsumTime": "2020-05-22 11:33",
          "storeName": "深大店",
          "cardLevel": "女王卡",
          "subcardNum": "5",
          "tmonreCharge": "100.00",
          "tmonBuy": "100.00",
          "tmonConsum": "100.00",
          "allCharge": "101.01",
          "allBuy": "101.01",
          "allConsum": "101.01",
        },
        {
          "imghUrl": "./images/demoimg.png",
          "name": "特朗普",
          "phone": "2311231231",
          "lastConsumTime": "2020-05-22 11:33",
          "storeName": "深大店",
          "cardLevel": "女王卡",
          "subcardNum": "5",
          "tmonreCharge": "100.00",
          "tmonBuy": "100.00",
          "tmonConsum": "100.00",
          "allCharge": "101.01",
          "allBuy": "101.01",
          "allConsum": "101.01",
        }
      ]
      ,
      "page2":[
        {
          "imghUrl": "./images/demoimg.png",
          "name": "特朗普",
          "phone": "2311231231",
          "lastConsumTime": "2020-05-22 11:33",
          "storeName": "深大店",
          "cardLevel": "女王卡",
          "subcardNum": "521",
          "tmonreCharge": "100.00",
          "tmonBuy": "100.00",
          "tmonConsum": "100.00",
          "allCharge": "101.01",
          "allBuy": "101.01",
          "allConsum": "101.01",
        },
        {
          "imghUrl": "./images/demoimg.png",
          "name": "特朗普",
          "phone": "2311231231",
          "lastConsumTime": "2020-05-22 11:33",
          "storeName": "深大店",
          "cardLevel": "女王卡",
          "subcardNum": "543",
          "tmonreCharge": "100.00",
          "tmonBuy": "100.00",
          "tmonConsum": "100.00",
          "allCharge": "101.01",
          "allBuy": "101.01",
          "allConsum": "101.01",
        },
        {
          "imghUrl": "./images/demoimg.png",
          "name": "特朗普",
          "phone": "2311231231",
          "lastConsumTime": "2020-05-22 11:33",
          "storeName": "深大店",
          "cardLevel": "女王卡",
          "tmonreCharge": "100.00",
          "tmonBuy": "100.00",
          "tmonConsum": "100.00",
          "allCharge": "101.01",
          "allBuy": "101.01",
          "allConsum": "101.01",
        }
      ]
    },
    // 渲染列表
    noticeList: [],
    //页码
    pageNum: 1,
    pages: 0
  },
  // 日期picker
  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  // *****分页处理*****
  /**
   * 页面触底事件的处理函数
   */
  reachbot: function() {
    console.log("进入触底函数")
    var that = this;
    if (!this.loading && this.data.pageNum < this.data.pages) {
      this.getMoreList();
    }else{
      console.log("--------")
      wx.showToast({
        title: '我也是有底线的~',
        icon:'none',
        duration:2500,
      })
    }
  },
  getMoreList: function(){
    this.loading = true
    console.log("请求分页")
    var that =this;
    (this.data.pageNum)++;
    this.setData({
      noticeList: that.data.noticeList.concat(that.data.demolist.page2)
    })
    this.loading = false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      noticeList: this.data.demolist.page1,
      pages: this.data.demolist.pages
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})